{include file="public/header"}

<body>

	<section id="container" class="">
		<!--header start-->
		{include file="public/headtop" /}
		<!--header end-->
		<!--sidebar start-->
		<aside>
			<div id="sidebar"  class="nav-collapse ">
				<!-- sidebar menu start-->
				{include file="public/menu" /}
				<!-- sidebar menu end-->
			</div>
		</aside>
		<!--sidebar end-->
		<!--main content start-->
		<section id="main-content">
			<section class="wrapper site-min-height">
				<!-- page start-->
				<div class="row">
					<div class="col-lg-12">
						{include file="public/nav" webnavname="用户组管理"}
					</div>
					<div class="col-lg-6">
						<div class="btn-group">
							<button id="editable-sample_new" class="btn green success" data-toggle="modal" href="#incGroup">
								新增用户组 <i class="fa fa-plus"></i>
							</button>
						</div>
						
					</div>
					<div class="col-lg-12">
						
						<section class="panel">
							<header class="panel-heading">
								用户组列表
							</header>
							<table class="table table-striped table-advance table-hover">
								<thead>
									<tr>
										<th><i class="fa fa-tag"></i> 组名</th>
										<th><i class="fa fa-btc"></i> 优惠</th>
										<th><i class="fa fa-plus-square"></i> 操作</th>
									</tr>
								</thead>
								<tbody>
									{volist name="groupList" id="group" empty="当前无数据"}
									<tr id="groupList_{$group.id}">
										<td>{$group.name}</td>
										<td>{$group.discount}</td>
										<td>
											<button class="btn btn-primary btn-xs"  onclick="getUserInfo({$group.id})"><i class="fa fa-pencil"></i></button>
											<button class="btn btn-danger btn-xs" data-toggle="modal" href="#delGroup" onclick="$('#GroupID').val({$group.id})"><i class="fa fa-trash-o "></i></button>
										</td>
									</tr>
									{/volist}
									
								</tbody>
							</table>

						</section>
					</div>
				</div>

				<div class="row">
					<div class="col-lg-12">
						<section class="panel">
							<div class="panel-body">
								<input type="hidden" name="GroupID" id="GroupID">
								<div class="modal fade  modal-dialog-center" id="delGroup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									<div class="modal-dialog modal-sm">
										<div class="modal-content-wrap">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title">是否删除该账户</h4>
												</div>
												<div class="modal-body">

													此账户一旦删除将无法还原，请谨慎操作！

												</div>
												<div class="modal-footer">
													<button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
													
													<button class="btn btn-warning" type="button" onclick="del($('#GroupID').val())"> 删除</button>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="modal fade" id="EchoMsg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									<div class="modal-dialog modal-sm">
										<div class="modal-content-wrap">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title">消息通知</h4>
												</div>
												<div class="modal-body text-center" id="msgVal">

												</div>
												<div class="modal-footer">
													<button class="btn btn-danger" type="button" data-dismiss="modal"> OK</button>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="modal fade  modal-dialog-center" id="updateGroup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content-wrap">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title">修改用户组信息</h4>
												</div>
												<div class="modal-body">

													<form role="form">
														<div class="form-group">
															<label>组名</label>
															<div class="iconic-input">
																<i class="fa fa-user"></i>
																<input type="text" class="form-control" name="groupName" id="groupName" placeholder="组名">
															</div>
														</div>
														<div class="fo
														<div class="form-group">
															<label>优惠</label>
															<div class="iconic-input">
																<i class="fa fa-envelope"></i>
																<input type="text" class="form-control" name="discount" id="discount" placeholder="优惠">
															</div>
														</div>
													</form>

												</div>
												<div class="modal-footer">
													<button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
													<button class="btn btn-warning" type="button" onclick="update($('#GroupID').val())"> 保存</button>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="modal fade  modal-dialog-center" id="incGroup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									<div class="modal-dialog">
										<div class="modal-content-wrap">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title">新增用户组</h4>
												</div>
												<div class="modal-body">

													<form role="form">
														<div class="form-group">
															<label>组名</label>
															<div class="iconic-input">
																<i class="fa fa-user"></i>
																<input type="text" class="form-control" name="groupName" id="groupName_inc" placeholder="组名">
															</div>
														</div>
														<div class="form-group">
															<label>优惠</label>
															<div class="iconic-input">
																<i class="fa fa-envelope"></i>
																<input type="text" class="form-control" name="discount" id="discount_inc" placeholder="优惠">
															</div>
														</div>

													</form>

												</div>
												<div class="modal-footer">
													<button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
													<button class="btn btn-warning" type="button" onclick="inc()"> 新增</button>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</section>
					</div>
				</div>
				<!-- page end-->
			</section>
		</section>
		<!--main content end-->
		<!-- Right Slidebar start -->
		{include file="public/slidright"}
		<!-- Right Slidebar end -->
		<!--footer start-->
		<footer class="site-footer">
			{include file="public/footer"}
		</footer>
		<!--footer end-->
	</section>

	<!-- js placed at the end of the document so the pages load faster -->
	<script src="__STATIC__/js/jquery.js"></script>
	<script src="__STATIC__/js/bootstrap.min.js"></script>
	<script class="include" type="text/javascript" src="__STATIC__/js/jquery.dcjqaccordion.2.7.js"></script>
	<script src="__STATIC__/js/jquery.scrollTo.min.js"></script>
	<script src="__STATIC__/js/jquery.nicescroll.js" type="text/javascript"></script>
	<script src="__STATIC__/js/respond.min.js" ></script>

	<!--right slidebar-->
	<script src="__STATIC__/js/slidebars.min.js"></script>


	<!--common script for all pages-->
	<script src="__STATIC__/js/common-scripts.js"></script>
	<script type="text/javascript">
		function del(id){
			$('#delGroup').modal('hide');
			$.post('', {id: id,type:'del'}, function(data, textStatus, xhr) {
				if(data.code==200){
					EchoMsg(data.msg,'/admin/group.html')
				}else{
					EchoMsg(data.msg,'/admin/group.html')
				}

			});
		}
		function update(id){
			$('#updateGroup').modal('hide');
			var name = $('#updateGroup #groupName').val();
			var discount = $('#updateGroup #discount').val();
			$.post('', {id: id,type:'update',name:name,discount:discount}, function(data, textStatus, xhr) {
				if(data.code==200){
					EchoMsg(data.msg,'/admin/group.html')
				}else{
					EchoMsg('修改失败:'+data.msg,'/admin/group.html')
				}

			});
		}
		function inc(){
			$('#incGroup').modal('hide');
			var name = $('#incGroup #groupName_inc').val();
			var discount = $('#incGroup #discount_inc').val();
			$.post('',{id:1,type:'inc',name:name,discount:discount},function(data){
				if(data.code==200){
					EchoMsg(data.msg,'/admin/group.html')
				}else{
					EchoMsg('新增失败:'+data.msg,'/admin/group.html')
				}
			});
		}
		function getUserInfo(id){
			var a = $('#groupList_'+id+' td');
			var groupName = a[0].textContent;
			var discount = a[1].textContent;
			$('#GroupID').val(id);
			$('#updateGroup #groupName').val(groupName);
			$('#updateGroup #discount').val(discount);
			$('#updateGroup').modal('show');
		}

		function EchoMsg(msg,local){
			$('#msgVal').html(msg);
			$('#EchoMsg').modal('show');
			if(local){
				$('#EchoMsg').on('hidden.bs.modal', function () {
					window.location.href = local;
				})
			}
		}
	</script>

</body>
</html>